package com.zx.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zx.cloud.ApiVersion;
import com.zx.cloud.common.filter.CurrentUserId;
import com.zx.cloud.controller.client.DictClient;
import com.zx.cloud.domain.Dict;
import com.zx.cloud.model.response.ObjectDataResponse;
import com.zx.cloud.util.Page;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * @author Alex
 */
@RestController
@RequestMapping(value = ApiVersion.MANAGER_V1_PREFIX + "/dict", produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public class DictController {

	@Autowired
	private DictClient dictClient;

	@ApiOperation(value = "查询字典内容", notes = "查询字典内容")
	@RequestMapping(value = "findDict", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Page<Dict>> findDict(@RequestBody Dict dict) {
		
		ObjectDataResponse<Page<Dict>> pageDict = dictClient.findDict(dict);
		return pageDict;
	}


	@ApiOperation(value = "修改字典内容", notes = "修改字典内容")
	@RequestMapping(value = "updateDict", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Integer> updateDict(@RequestBody Dict dict) {
		
		ObjectDataResponse<Integer> success = dictClient.updateDict(dict);
		return success;
	}

	@ApiOperation(value = "添加字典内容", notes = "添加字典内容")
	@RequestMapping(value = "addDict", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Integer> addDict(@RequestBody Dict dict) {
		
		ObjectDataResponse<Integer> success = dictClient.addDict(dict);
		return success;
	}
	
	@ApiOperation(value = "查询父类字典内容", notes = "查询字典内容")
	@RequestMapping(value = "queryPageByParent", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Page<Dict>> queryPageByParent(@RequestBody Dict dict) {
		
		ObjectDataResponse<Page<Dict>>  pageDict = dictClient.queryPageByParent(dict);
		return pageDict;
	}
	

}
